<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>佣金转余额</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="__INDEX__/css/style.css"/>
		<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
		<link rel="stylesheet" href="__INDEX__/css/mall.css" />
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
		    <h1 class="mui-title">佣金转余额</h1>
		</header>
		<div class="mui-content yongj_content">
			<div class="yjzye_top"><span class="nam" style="line-height: 21px; padding-top: 10px;">当前<br />佣金</span><span class="iconfont icon-jiantou1"></span><span class="nam">余额</span></div>
		    <div class="tixian_pri">
		    	<p>提现到余额(扣除5%服务费)/可提现佣金：<em id='yongj'>{$info_user['commission']}</em></p>
		    	<p class="tixian_prinum clearfix">
		    		<label>¥</label>
		    		<input type="text" placeholder="" id='commission'  onkeyup="clearNoNum(this)"/>
		    	</p>
		    </div>
		    <button class="tixian_btn" onclick="to_money()">确认</button>
		</div>
	</body>
</html>
{include file="public/footer" /}
<script>
	//只能数字和小数点
	function clearNoNum(obj) {
		obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
		obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
		obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
		obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
	}
	
	function to_money(){
		var cut_commission = "{$info_user['commission']}";
		var to_num = $('#commission').val();
		
		if(to_num.trim() == "" || to_num<10){
			layer.msg('金额不能小于10！');
			return ;
		}
		
		
		if(to_num > cut_commission){
			layer.msg('鼓励金不足！');
			return ;
		}
		
		$.ajax({
             	type:"post",
                url:"{:url('index/member/yongj_yue')}",
                data: {
                	commission	: $('#commission').val()
                },
                success:function(data){
                   layer.msg(data.msg, {
						  icon: 1,
						  time: 1500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							parent.location.reload();
						});
                },error:function(data){
                	var a = data;
                }
        });
	}
</script>